<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status']=$this->hetong_status;
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>1);
	if(!empty($_RQ['sn'])){
		$params['sn like']='%'.trim($_RQ['sn']).'%';
		$return['params']['sn']=$_RQ['sn'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile like']='%'.trim($_RQ['mobile']).'%';
		$return['params']['mobile']=$_RQ['mobile'];
	}
	if(!empty($_RQ['status'])){
		$params['status']=trim($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_aihire_gongfee',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
		$item['merchtitle']=pdo_getcolumn('jy_aihire_merch',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['merchid']),'title');
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'点工费发放'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(	
			array('name'=>'merchtitle','title'=>'付款方','type'=>'string'),
			array('name'=>'sn','title'=>'付款编号','type'=>'string'),
			array('name'=>'title','title'=>'付款名称','type'=>'string'),
			array('name'=>'famonth','title'=>'发放日期','type'=>'image'),
			array('name'=>'num','title'=>'发放人数','type'=>'image'),
			array('name'=>'fee','title'=>'发放金额','type'=>'video'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'uptime','title'=>'发放时间','type'=>'time'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal','op'=>'look','title'=>'详情'),
		)),
		'search'=>array(
			array('name'=>'sn','width'=>10,'title'=>'付款编号','type'=>'string'),
			array('name'=>'status','width'=>10,'title'=>'状态','type'=>'radio','options'=>'status'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='look'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_aihire_gongfee',array('id'=>$id));
	}else{
		$item=array();
	}
    $return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'desc'=>'点工费列表详情',
		'tabs'=>array(
			array('op'=>'list','title'=>'点工费列表'),
		),
		'look'=>array(
			array('name'=>'merchtitle','title'=>'付款方','type'=>'string'),
			array('name'=>'sn','title'=>'付款编号','type'=>'string'),
			array('name'=>'title','title'=>'付款名称','type'=>'string'),
			array('name'=>'month','title'=>'所属月份','type'=>'image'),
			array('name'=>'famonth','title'=>'发放月份','type'=>'image'),
			array('name'=>'num','title'=>'发放人数','type'=>'image'),
			array('name'=>'fee','title'=>'发放金额','type'=>'video'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_aihire_gongfee',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_aihire_gongfee',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>